﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace _031_自定义封装集合类型成员的XML元素
{
    class Program
    {
        static void Main(string[] args)
        {
            using (MemoryStream 操作=new MemoryStream())
            {
                先声明的类 手柄 = new 先声明的类
                {
                    Values = new double[]
                    {
                        0.33d,1.1005d,12.456d
                    },
                    StringList = new List<string>
                    {
                        "Test 1","Test 2","Test 3"
                    }
                };
                XmlSerializer 数据方法 = new XmlSerializer(typeof(先声明的类));
                数据方法.Serialize(操作, 手柄);

                //输出XML文档
                操作.Position = 0L;
                using (StreamReader 读取来=new StreamReader(操作))
                {
                    Console.WriteLine(读取来.ReadToEnd());
                }
                    
            }
            Console.Read();

        }
    }
    public class 先声明的类
    {
        public double[] Values { get; set; }
        [XmlArray("Strs")]
        public List<string> StringList { get; set; }
    }
}
